<?php
class BlogRelationModel extends RelationModel{
  protected $tableName ='blog';
  
  protected $_link=array(
       'attr'=>array(
         'mapping_type'=>MANY_TO_MANY,
        'mapping_name'=>'attr',
         'foreign_key'=>'bid',
         "relation_foreign_key"=>'aid',
         'relation_table'=>'blog_attr'
       	),
       'cate'=>array(
        'mapping_type'=>BELONGS_TO, 
        'foreign_key'=>'cid',
        'as_fields'=>'name:cate',
         //'class_name'=>'cate',
         // 'mapping_name'=>'cate'
           ),

  	);

  public function GetBlog($type=0){
     //$fields=array("del");     
       $where=array('del'=>$type);
  
       $blog= $this->relation(true)->where($where)->order('time DESC')->select();

       return $blog;
  }

}



?>